package Java_IO;

import java.io.IOException;

/**
 * @author shy_black
 * @date 2019/3/20 10:51
 * @Description:
 */
class CloseTest implements AutoCloseable {
    @Override
    public void close() throws Exception {
        System.out.println("自动调用close方法");
    }
    public void fun() {
        System.out.println("普通方法");
    }
}


public class AutoCloseable_test {
    public static void main(String[] args)throws Exception {
        try(CloseTest closeTest = new CloseTest()) {
            closeTest.fun();
        }catch(IOException e) {
            e.printStackTrace();
        }
    }
}
